﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jzy.Core.Common;
using FortuneHeavenDAL;
using FortuneHeavenCommon.DataMap;

namespace FortuneHeavenBAL
{
    public class AdminUserBO : CommonOperate<AdminUser>
    {
        public AdminUserDAL _roleDAL;
        public AdminUserBO()
            : base()
        {
            _roleDAL = new AdminUserDAL();
        }


        public List<AdminUser> GetUserButAdmin(int page, int size)
        {
            return _roleDAL.GetUserButAdmin(page, size);
        }

        public int GetTotalSize()
        {
            return _roleDAL.GetTotalSize();
        }

        public AdminUser GetUser(int id)
        {
            if (id < 0)
                return null;

            AdminUser user = this.GetInfo(id);
            RoleBO roleBo = new RoleBO();
            user.RoleList = roleBo.GetList(GetRolesID(user.Roles));
            return user;
        }

        private List<string> GetRolesID(string input)
        {
            List<string> content = new List<string>();
            if (!string.IsNullOrEmpty(input))
            {
                string[] con = input.Split(',');
                foreach (string t in con)
                {
                    content.Add(t);
                }
            }
            return content;
        }

        public AdminUser CheckUserPwd(string user, string password)
        {
            return _roleDAL.CheckUserPwd(user, password);
        }

    }
}
